<?php

namespace IDock\Insurance\ZMBX\Response;

use IDock\Http\Response;
use IDock\IDock\IDock;
use IDock\IDock\IDockEnums;
use IDock\Insurance\ZMBX\Response\AllZMBXResponse;
use IDock\Printer\ProposalStatusPrinter;

class ProposalStatusResponse extends AllZMBXResponse
{

    /**
     * @var ProposalStatusPrinter $printer
     */
    public $printer = ProposalStatusPrinter::class;

    public function printerInit(): Response
    {
        $body = $this->getBody() ?? [];
        $code = $body['underWriteInd'] ?? '';
        $this->printer->messageTip = $code;
        //核保失败
        if (in_array($code,['核保不通过','复核不通过'])) {
            $this->printer->statusCode = 'U4';
        }
        //成功
        if (in_array($code,['自动核保','核保通过','复核通过','承保确认']))  {
            $this->printer->statusCode = 'U1';
        }
        //人工
        if (in_array($code,['初始状态','待复核','待核保'])) {
            $this->printer->statusCode = 'U3';
        }
        //拒保
        if ($code == '拒保') {
            $this->printer->statusCode = 'U6';
        }
        $this->printer->status = IDockEnums::$underStats[$this->printer->statusCode];

        return $this;
    }
}
